package com.example.cdmuseum.ui.fragment;

import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.example.cdmuseum.R;
import com.example.cdmuseum.ui.activity.NewsdetailsActivity;
import com.example.cdmuseum.base.LazyFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;


public class NewsFragment extends LazyFragment {

    private ArrayAdapter<String> adapter;
    private List<String> list_news;
    private List<String> list_news_url;


//    @BindView(R.id.tv_return_news)
//    TextView tv_return_news;

    @BindView(R.id.listview_news)
    ListView listview_news;

//
//    @OnClick({R.id.tv_return_news})
//    public void onClick(View view) {
//
//        switch (view.getId()) {
//            case R.id.ll_intro: {
//                showToast("Hello");
////                startActivity(new Intent(getContext(), IntroActivity.class));
//            }
//            break;
//        }
//    }

    private void initNews() {
        list_news = new ArrayList<String>();
        list_news_url = new ArrayList<String>();

        list_news.add("非遗日抢先睇丨6月8日，全省武林高手“武动”佛山！吹响广东非遗美食集结号！");
        list_news_url.add("https://mp.weixin.qq.com/s/BdfaOoRW4r1YO99Qvy6cfQ");


        list_news.add("文化和自然遗产日∣“佛山非遗知多D”有奖答题活动");
        list_news_url.add("https://mp.weixin.qq.com/s/xzW3fKA8oe30jgY0_uK-ew");


        list_news.add("龙舟即将开飙！“博物讲坛” 走进环湖小学 传播龙舟文化");
        list_news_url.add("https://mp.weixin.qq.com/s/o237TbvsqKLlzY3n1XjLWw");


        list_news.add("活动报名 | 乘风破浪，端午呈祥——佛山市博物馆文化和自然遗产日系列活动");
        list_news_url.add("https://mp.weixin.qq.com/s/bnHznADVVCekkHhrTO8gwQ");


        list_news.add("活动回顾 | 传非遗，悦童心——佛山市博物馆文化和自然遗产日系列活动");
        list_news_url.add("https://mp.weixin.qq.com/s/VX1moXkK9expelOQP5Guyw");


        list_news.add("晒宝 | “历史祖庙”专题展中的馆藏文献");
        list_news_url.add("https://mp.weixin.qq.com/s/Kq5_15d2IWxzwGNDEU6JAA");


        list_news.add("晒宝 | “历史祖庙”专题展中的馆藏碑拓");
        list_news_url.add("https://mp.weixin.qq.com/s/NAvNIEqV7ojQE5MdW5U0gw");


        list_news.add("博物讲坛走进“佛大”，佛山秋色魅力让学子大开眼界");
        list_news_url.add("https://mp.weixin.qq.com/s/mS4Ur7Tscugtr2W_efrx8g");


        list_news.add("佛山史话 | 龙船漂移，为什么在叠滘？");
        list_news_url.add("https://mp.weixin.qq.com/s/IwAVhldwDQbt3sky1YyB-w");
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_news;
    }

    @Override
    protected void loadData() {
        initNews();
        adapter = new ArrayAdapter<String>(
                getContext(), android.R.layout.simple_expandable_list_item_1, list_news);
        listview_news.setAdapter(adapter);

        listview_news.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent(getContext(), NewsdetailsActivity.class);
                intent.putExtra("title", list_news.get(position));
                intent.putExtra("url", list_news_url.get(position));

                startActivity(intent);
            }
        });
    }


}